package com.abe.mvp.presenter;

import com.abe.mvp.contact.WebServerContact;
import com.abe.mvp.contact.WebServerContact.Model.IWebServerBack;
import com.abe.mvp.model.WebServerModelImp;
import com.abe.mvp.model.bean.http.ScanBean;

public class HttpQRCodePresenterImp implements WebServerContact.QRCodePresenter {

	private WebServerContact.Model mModel;
	private WebServerContact.QRCodeView mView;

	public HttpQRCodePresenterImp(WebServerContact.QRCodeView mView) {
		this.mView = mView;
		this.mModel = new WebServerModelImp();
	}

	@Override
	public void getQRCode() {
		mModel.getQRCode(new IWebServerBack() {
			@Override
			public void onResult(int code, Object data, String errorMSG) {
				if (code == 1) {
					mView.onGetQRCodeSuccess((ScanBean) data);
				} else {
					mView.onRequestFail(errorMSG);
				}
			}

			@Override
			public void onFinish() {
				mView.onFinish(WebServerContact.TYPE_QR);
			}
		});
	}

}
